package com.cn.ZhiKeDianShang.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import com.cn.ZhiKeDianShang.R;
import com.cn.ZhiKeDianShang.base.RecycleAndListBaseAdapter.RecycleBaseAdapter.RecycleBaseViewHolder;
import com.cn.ZhiKeDianShang.base.RecycleAndListBaseAdapter.RecycleBaseAdapter.RecycleListBaseAdapter;
import com.cn.ZhiKeDianShang.model.response.BlList;

import java.util.List;


public class DeclarationAdapter extends RecycleListBaseAdapter<BlList.BdBean> {

    private Context mContext;
    private Animation mLikeAnim;
    private onItemClick onItemClick;

    public DeclarationAdapter(Context context, int layoutId, List<BlList.BdBean> datas, onItemClick onItemClick) {
        super(context, layoutId, datas);
        this.mContext = context;
        mLikeAnim = AnimationUtils.loadAnimation(context, R.anim.anim_like);
        this.onItemClick = onItemClick;
    }


    @Override
    public void convert(RecycleBaseViewHolder helper, BlList.BdBean relatedBean, int position) {
        helper.setText(R.id.tv_title, relatedBean.getNickname() + "");
        helper.setText(R.id.tv_bianhao, relatedBean.getDate() + "");
        helper.setText(R.id.tv_number, relatedBean.getNum() + "");
        TextView tv_delete = (TextView) helper.getView(R.id.tv_delete);
        TextView tv_update = (TextView) helper.getView(R.id.tv_update);
        tv_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onItemClick.deal(position);
            }
        });

        tv_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onItemClick.update(position);
            }
        });
    }

    @Override
    public void convert(RecycleBaseViewHolder helper, BlList.BdBean tiktokBean, List<Object> payloads, int position) {
        Log.d("Debug", "到达局部刷新这里-------------------->>>>payloads" + payloads);
    }


    public interface onItemClick {
        void update(int position);

        void deal(int position);

    }
}
